<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<body>
<p>This tests our ability to correctly select radio buttons when we have nested label tags. This test 
only works in DumpRenderTree. It can be tested manually outside of DRT just by clicking around.</p>

<form>
    <input  type="radio" name="chkPlan" id="one"><label for="one">one
    <input  type="radio" name="chkPlan" id="two"><label for="two">two
    <input  type="radio" name="chkPlan" id="three"><label for="three">three
    <input  type="radio" name="chkPlan" id="four"><label for="four">four
</form>

<script>
test(() => {
  assert_not_equals(window.eventSender, undefined, 'This test requires eventSender to simulate mouse operations');

  var radioFour = document.getElementById('four');
  var radioX = radioFour.offsetLeft + radioFour.offsetWidth / 2;
  var radioY = radioFour.offsetTop + radioFour.offsetHeight / 2;

  eventSender.mouseMoveTo(radioX, radioY);
  eventSender.mouseDown();
  eventSender.mouseUp();

  assert_true(radioFour.checked);
}, 'Select radio buttons in nested label tags');
</script>
</body>
